<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="header::header" />
<body>
	<div id="dgtoolbar" class="datagrid-toolbar">
		<span>企业名称：</span>
		<input id="q_cname" class="easyui-textbox" style="width: 200px" data-options=""></input>
		<span>企业类型：</span>
		<input id="q_itype" class="easyui-combobox" style="width: 200px" data-options="panelHeight:'auto',url:'../dicdetails/findItems?ckey=companytype',valueField:'cvalue',textField:'cname',editable:false"></input>
		<a id="querybtn" href="#" class="easyui-linkbutton" iconCls="icon-search" plain="true" title="查询" onclick="subQueryHandler()">查询</a>
		<a id="reset" href="#" class="easyui-linkbutton" iconCls="icon-reload" plain="true" onclick="reset()">重置</a>
		<a id="newbtn" href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" title="新增">新增</a>
		<a id="deletebtn" href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" title="批量删除">删除</a>
		<a id="reloadbtn" href="#" class="easyui-linkbutton" iconCls="icon-reload" plain="true">刷新</a>
		<a id="exportbtn" href="#" class="easyui-linkbutton" iconCls="icon-folder" plain="true" onclick="onOpenImportDlg()">导入</a>
	</div>
	<!-- 表格 -->
	<table id="dg" class="easyui-datagrid" data-options="url:'pageQuery',idField:'iid',rownumbers:true,singleSelect:false,method:'post',toolbar:'#dgtoolbar',pagination:true,pageSize:20,pageList:[20,30,50],fit:true,onLoadSuccess:onDGLoadSuccess">
		<thead>
			<tr>
				<th data-options="field:'iid'" checkbox="true"></th>
				<th data-options="field:'cname'" width="100" align="center">企业名称</th>
				<th data-options="field:'cshort'" width="100" align="center">企业简称</th>
				<th data-options="field:'caddress'" width="100" align="center">企业地址</th>
				<th data-options="field:'clinkman'" width="80" align="center">联系人</th>
				<th data-options="field:'cphone'" width="80" align="center">联系电话</th>
				<th data-options="field:'cemail'" width="80" align="center">邮箱</th>
				<th data-options="field:'ctype'" width="80" align="center">企业类型</th>
				<th data-options="field:'cmainbusiness'" width="80" align="center">主营业务</th>
				<th data-options="field:'cadvantages'" width="80" align="center">企业优势</th>
				<th data-options="field:'cintroduction'" width="80" align="center">团队简介</th>
				<th data-options="field:'ccreator'" width="80" align="center">添加人</th>
				<th data-options="field:'dcreator'" width="150" align="center">添加时间</th>
				<th data-options="field:'cmodify'" width="80" align="center">修改人</th>
				<th data-options="field:'dmodify'" width="150" align="center">修改时间</th>
				<!-- <th data-options="field:'ccomment'" 	width="200" 	align="center">备注</th> -->
				<th data-options="field:'opt',formatter:onItemOptEdit" width="40" align="center">修改</th>
				<th data-options="field:'opt1',formatter:onItemOptDelete" width="40" align="center">删除</th>
				<th data-options="field:'opt2',formatter:onItemOptShow" width="40" align="center">查看</th>
			</tr>
		</thead>
	</table>
	<!-- 弹出框 -->
	<div id="dlg" class="easyui-dialog" title="操作" style="padding:5px" data-options="buttons: '#dlg-buttons',closed:'true',modal:true">
		<form id="dataform" method="post" enctype="multipart/form-data">
			<table>
				<tr></tr>
				<tr>
					<td>企业名称:</td>
					<td><input name="iid" id="iid" type="hidden"></input> 
					<input name="cpicname" id="cpicname" type="hidden">
					<input name="cpicpath" id="cpicpath" type="hidden">
					<input name="cpicsize" id="cpicsize" type="hidden">
					<input name="ctype" id="ctype" type="hidden"></input> <input name="cname" class="easyui-textbox" style="width: 200px" data-options="required:true"></input></td>
				</tr>
				<tr>
					<td>企业简称:</td>
					<td><input name="cshort" id="cshort" class="easyui-textbox" style="width: 200px" data-options="required:true"></input></td>
				</tr>
				<tr>
					<td>企业地址:</td>
					<td><input name="caddress" id="caddress" class="easyui-textbox" style="width: 200px" data-options="required:true"></input></td>
				</tr>
				<tr>
					<td>联系人:</td>
					<td><input name="clinkman" id="clinkman" class="easyui-textbox" style="width: 200px" data-options="required:true"></input></td>
				</tr>
				<tr>
					<td>联系电话:</td>
					<td><input name="cphone" id="cphone" class="easyui-textbox" style="width: 200px" data-options="required:true"></input></td>
				</tr>
				<tr>
					<td>邮箱:</td>
					<td><input name="cemail" id="cemail" class="easyui-textbox" style="width: 200px" data-options="required:true"></input></td>
				</tr>
				<tr>
					<td>企业类型:</td>
					<td><input name="itype" id="itype" class="easyui-combobox" style="width: 200px" data-options="panelHeight:'auto',url:'../dicdetails/findItems?ckey=companytype',valueField:'cvalue',textField:'cname',editable:false"></input></td>
				</tr>
				<tr>
					<td>主营业务:</td>
					<td><input name="cmainbusiness" id="cmainbusiness" class="easyui-textbox" style="width: 200px;height: 60px;" data-options="required:true,multiline:true"></input></td>
				</tr>
				<tr>
					<td>企业优势:</td>
					<td><input name="cadvantages" id="cadvantages" class="easyui-textbox" style="width: 200px;height: 60px;" data-options="required:true,multiline:true"></input></td>
				</tr>
				<tr>
					<td>团队简介:</td>
					<td><input name="cintroduction" id="cintroduction" class="easyui-textbox" style="width: 200px;height: 60px;" data-options="required:true,multiline:true"></input></td>
				</tr>
				<tr>
					<td>上传文件:</td>
					<td><input type="file" name="upfile" id="upfile"></input></td>
				</tr>
			</table>
		</form>
	</div>
	<!-- 弹出框工具栏 -->
	<div id="dlg-buttons">
		<a id="dlg-savebtn" href="javascript:void(0)" style="width:70px" class="easyui-linkbutton" iconCls="icon-ok">保存</a>
		<a id="dlg-closebtn" href="javascript:void(0)" style="width:70px" class="easyui-linkbutton" iconCls="icon-no">关闭</a>
	</div>
	<!-- 弹出框 -->
	<div id="dlg-import" class="easyui-dialog" title="导入文件" style="width:300px;padding:5px" data-options="buttons: '#dlg-import-buttons',closed:'true',modal:true">
		<form id="dataform-import" method="post" enctype="multipart/form-data">
			<table>
				<tr>
					<td>文件:</td>
					<td><input name="filedata" id="filedata" type="file" style="width: 200px" data-options="required:true"></input></td>
				</tr>
			</table>
		</form>
	</div>
	<!-- 弹出框工具栏 -->
	<div id="dlg-import-buttons">
		<a id="dlg-importbtn" href="javascript:void(0)" style="width:50" class="easyui-linkbutton" iconCls="icon-ok" onclick="onUploadFile()">导入</a> <a id="dlg-importclosebtn" href="javascript:void(0)" style="width:50" class="easyui-linkbutton" iconCls="icon-no" onclick="$('#dlg-import').dialog('close');">关闭</a>
	</div>
</body>
<script type="text/javascript" th:src="@{/common/GridView.js}"></script>
<script type="text/javascript">
	$(document).ready(function() {
		$("#itype").combobox({
			"onChange" : function() {

				var type = $('#itype').combobox('getText');
				$('#ctype').val(type);

			}

		});

	})

	function subQueryHandler() {
		var itype = $("#q_itype").combobox("getValue");
		if (itype == null || "" == itype) {
			itype = 0
		}
		$("#dg").datagrid("load", {
			cname : $("#q_cname").textbox("getValue"),
			itype : itype

		});
	}
	function reset() {
		$("#q_cname").textbox("setValue", "");
		$("#q_itype").combobox("setValue", "");
	}
	function exportbtn(){

	}
    function onOpenImportDlg() {
        $("#dataform-import").form("clear");
        $("#dlg-import").dialog("open");
    }

    //上传文件
    function onUploadFile() {
        $("#dataform-import").form("submit", {
            url : "importXls.do",
            async : false,
            onSubmit : function() {
                var bool = $("#dataform-import").form("validate");
                if(bool){
                    $("#dlg-import").dialog("close");
                }
                return bool;
            },
            success : function(data) {
                var obj = eval('(' + data + ')');
                $.messager.alert("提示", obj.msg);
                if(obj.success){
                    $("#dg").datagrid("reload");
                    $("#dg").datagrid("unselectAll");
                }
            },
            error : function(result) {
                alert("result:" + result);
            }
        });
    }
</script>
</html>